package com.ruoyi.web.controller.bussiness;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.TAiProductCategories;
import com.ruoyi.bussiness.service.ITAiProductCategoriesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品分类（中英文）Controller
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@RestController
@RequestMapping("/bussiness/categories")
public class TAiProductCategoriesController extends BaseController
{
    @Autowired
    private ITAiProductCategoriesService tAiProductCategoriesService;

    /**
     * 查询产品分类（中英文）列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:categories:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAiProductCategories tAiProductCategories)
    {
        startPage();
        List<TAiProductCategories> list = tAiProductCategoriesService.selectTAiProductCategoriesList(tAiProductCategories);
        return getDataTable(list);
    }

    /**
     * 导出产品分类（中英文）列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:categories:export')")
    @Log(title = "产品分类（中英文）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAiProductCategories tAiProductCategories)
    {
        List<TAiProductCategories> list = tAiProductCategoriesService.selectTAiProductCategoriesList(tAiProductCategories);
        ExcelUtil<TAiProductCategories> util = new ExcelUtil<TAiProductCategories>(TAiProductCategories.class);
        util.exportExcel(response, list, "产品分类（中英文）数据");
    }

    /**
     * 获取产品分类（中英文）详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:categories:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tAiProductCategoriesService.selectTAiProductCategoriesById(id));
    }

    /**
     * 新增产品分类（中英文）
     */
    @PreAuthorize("@ss.hasPermi('bussiness:categories:add')")
    @Log(title = "产品分类（中英文）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAiProductCategories tAiProductCategories)
    {
        return toAjax(tAiProductCategoriesService.insertTAiProductCategories(tAiProductCategories));
    }

    /**
     * 修改产品分类（中英文）
     */
    @PreAuthorize("@ss.hasPermi('bussiness:categories:edit')")
    @Log(title = "产品分类（中英文）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAiProductCategories tAiProductCategories)
    {
        return toAjax(tAiProductCategoriesService.updateTAiProductCategories(tAiProductCategories));
    }

    /**
     * 删除产品分类（中英文）
     */
    @PreAuthorize("@ss.hasPermi('bussiness:categories:remove')")
    @Log(title = "产品分类（中英文）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tAiProductCategoriesService.deleteTAiProductCategoriesByIds(ids));
    }
}
